import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/execute_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/application/special_list/work_mode_config_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/special_operation/special_list/job_ticket/common/common_work_detail_all/work_detail/work_detail_controller.dart';

///特殊作业-详情页面
class WorkDetailWidget extends StatelessWidget {
  WorkDetailWidget({
    required this.ticketReceiptId,
    super.key,
  });
  final String ticketReceiptId;
  final controller = Get.put(WorkDetailController());

  ///详情样式框
  Widget _getDetailStyleBox({String name = '', Widget? child}) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w),
      decoration: BoxDecoration(
        color: const Color(0xffffffff),
        borderRadius: BorderRadius.circular(12.r),
      ),
      child: Column(
        children: [
          name.isEmpty
              ? Container()
              : Row(
                  children: [
                    Container(
                      height: 14.w,
                      width: 3.w,
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.only(
                            topRight: Radius.circular(90.w),
                            bottomLeft: Radius.circular(20.w),
                            bottomRight: Radius.circular(20.w)),
                        gradient: LinearGradient(
                            //渐变位置
                            begin: Alignment.topCenter,
                            end: Alignment.bottomCenter,
                            //渐变颜色[始点颜色, 结束颜色]
                            colors: [
                              const Color(0xff587DF5),
                              const Color(0xff587DF5),
                              const Color(0xff587DF5).withOpacity(0.6)
                            ]),
                      ),
                    ),
                    AppGaps.hGap10,
                    Expanded(
                      child: Text(
                        name,
                        maxLines: 1,
                        style: TextStyle(
                          fontSize: 16.sp,
                          fontWeight: FontWeight.w500,
                          color: const Color(0xff262F38),
                        ),
                      ),
                    ),
                  ],
                ),
          child == null ? Container() : AppGaps.vGap14,
          child ?? Container()
        ],
      ),
    );
  }

  ///蓝色字体-灰色圆角背景
  Widget _getBlueTextGreyBg({String text = ''}) {
    return Container(
      alignment: Alignment.centerLeft,
      padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 4.w),
      decoration: BoxDecoration(
        color: const Color(0xffF5F6FA),
        borderRadius: BorderRadius.circular(4.r),
      ),
      child: Text(
        text,
        style: TextStyle(
          fontSize: 12.sp,
          fontWeight: FontWeight.w400,
          color: const Color(0xff5C6DFF),
        ),
      ),
    );
  }

  ///左侧名称-右侧内容-左右布局
  ///[name]名称
  ///[content]内容
  ///[nameColor]名称颜色
  ///[contentColor]内容颜色
  ///[margin]外边距
  Widget _getLeftNameRightContent(
      {String name = '',
      String content = '',
      Color? nameColor,
      Color? contentColor,
      EdgeInsetsGeometry margin = const EdgeInsets.only(bottom: 10)}) {
    return Container(
      margin: margin,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Expanded(
              flex: 1,
              child: Text(
                name,
                style: TextStyle(
                  fontSize: 13.sp,
                  fontWeight: FontWeight.w400,
                  height: 1.2,
                  color: nameColor ?? const Color(0xffA0A7B5),
                ),
              )),
          AppGaps.hGap10,
          Expanded(
              child: Container(
                  alignment: Alignment.centerRight,
                  child: Text(
                    content,
                    style: TextStyle(
                      fontSize: 13.sp,
                      height: 1.2,
                      fontWeight: FontWeight.w400,
                      color: contentColor ?? const Color(0xff495061),
                    ),
                  )))
        ],
      ),
    );
  }

  ///气体分析样式
  Widget _getGasAnalysisView(ExecuteTicketGasList gasAnalysis) {
    return Container(
      alignment: Alignment.centerLeft,
      padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 16.w),
      decoration: BoxDecoration(
        color: const Color(0xffF7F7F7),
        borderRadius: BorderRadius.circular(4.r),
      ),
      child: Column(
        children: [
          _getLeftNameRightContent(
            name: '气体取样分析时间：',
            content: gasAnalysis.sampleDate!,
            nameColor: const Color(0xff444444),
            contentColor: const Color(0xff3B62FF),
          ),
          _getLeftNameRightSign(
            name: '分析人',
            nameColor: const Color(0xff444444),
            sign: gasAnalysis.sampleUserSign!,
          ),
          _getLeftNameRightContent(
            name: '分析点名称：',
            content: gasAnalysis.addressName!,
            nameColor: const Color(0xff444444),
            contentColor: const Color(0xff3B62FF),
            margin: EdgeInsets.zero,
          ),
          Container(
            margin: EdgeInsets.symmetric(vertical: 10.w),
            child: Divider(
              height: 1.w,
              color: AppColors.button_grey,
            ),
          ),
          ListView.builder(
              itemCount: gasAnalysis.workGasJsonDTOList!.length,
              shrinkWrap: true,
              physics: const BouncingScrollPhysics(),
              itemBuilder: (context, index) {
                return _getGasAnalysisByType(gasAnalysis.workGasJsonDTOList![index],
                    index == gasAnalysis.workGasJsonDTOList!.length - 1);
              }),
        ],
      ),
    );
  }

  ///根据不同类型获取气体分析数据显示
  Widget _getGasAnalysisByType(ExecuteTicketGasListWorkGasJsonDTOList bean, bool isLast) {
    switch (controller.ticketBigTypeName) {
      case '动火作业':
        return _getFireGasAnalysisView(bean, isLast);
      case '受限空间':
        return _getRestrictedGasAnalysisView(bean, isLast);
      case '临时用电':
        return _getElectricityGasAnalysisView(bean, isLast);
      default:
        return Container();
    }
  }

  ///气体分析节点-动火作业
  Widget _getFireGasAnalysisView(ExecuteTicketGasListWorkGasJsonDTOList bean, bool isLast) {
    return Column(
      children: [
        _getLeftNameRightContent(
          name: '代表气体：',
          content: bean.gasName!,
          nameColor: const Color(0xff444444),
          contentColor: const Color(0xff3B62FF),
        ),
        _getLeftNameRightContent(
          name: '分析结果：',
          content: bean.gasResult!,
          nameColor: const Color(0xff444444),
          contentColor: const Color(0xff3B62FF),
          margin: EdgeInsets.zero,
        ),
        Container(
          margin: EdgeInsets.only(top: 10.w, bottom: isLast ? 0 : 10.w),
          child: Divider(
            height: 1.w,
            color: AppColors.button_grey,
          ),
        ),
      ],
    );
  }

  ///气体分析节点-受限空间
  Widget _getRestrictedGasAnalysisView(ExecuteTicketGasListWorkGasJsonDTOList bean, bool isLast) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          bean.gasTypeName!,
          style: TextStyle(
            fontSize: 14.sp,
            fontWeight: FontWeight.w400,
            height: 1.2,
            color: const Color(0xff444444),
          ),
        ),
        AppGaps.vGap12,
        Visibility(
            visible: bean.gasTypeName! != '氧气含量',
            child: _getLeftNameRightContent(
              name: '代表气体：',
              content: bean.gasName!,
              nameColor: const Color(0xff444444),
              contentColor: const Color(0xff3B62FF),
            )),
        _getLeftNameRightContent(
          name: '合格标准：',
          content: bean.gasQualified!,
          nameColor: const Color(0xff444444),
          contentColor: const Color(0xff3B62FF),
        ),
        _getLeftNameRightContent(
          name: '分析结果：',
          content: bean.gasResult!,
          nameColor: const Color(0xff444444),
          contentColor: const Color(0xff3B62FF),
          margin: EdgeInsets.zero,
        ),
        Container(
          margin: EdgeInsets.only(top: 10.w, bottom: isLast ? 0 : 10.w),
          child: Divider(
            height: 1.w,
            color: AppColors.button_grey,
          ),
        ),
      ],
    );
  }

  ///气体分析节点-受限空间
  Widget _getElectricityGasAnalysisView(ExecuteTicketGasListWorkGasJsonDTOList bean, bool isLast) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          bean.gasTypeName!,
          style: TextStyle(
            fontSize: 14.sp,
            fontWeight: FontWeight.w400,
            height: 1.2,
            color: const Color(0xff444444),
          ),
        ),
        AppGaps.vGap12,
        _getLeftNameRightContent(
          name: '代表气体：',
          content: bean.gasName!,
          nameColor: const Color(0xff444444),
          contentColor: const Color(0xff3B62FF),
        ),
        _getLeftNameRightContent(
          name: '分析结果：',
          content: bean.gasResult!,
          nameColor: const Color(0xff444444),
          contentColor: const Color(0xff3B62FF),
          margin: EdgeInsets.zero,
        ),
      ],
    );
  }

  ///安全措施样式
  Widget _getSafetyMeasuresView(ExecuteWorkSafetyMeasuresList safetyMeasures) {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 16.w),
      decoration: BoxDecoration(
        color: const Color(0xffF7F7F7),
        borderRadius: BorderRadius.circular(4.r),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            safetyMeasures.safetyMeasures!,
            style: TextStyle(
              fontSize: 13.sp,
              fontWeight: FontWeight.w400,
              color: const Color(0xff495061),
            ),
          ),
          AppGaps.vGap14,
          Row(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              safetyMeasures.images!.isEmpty
                  ? Container()
                  : Container(
                      width: 80.w,
                      height: 80.w,
                      decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.circular(4.w),
                          image: DecorationImage(
                            image: NetworkImage(Interface.fileUrl + safetyMeasures.images![0]),
                            fit: BoxFit.fill,
                          )),
                    ).clickShowLarge(url: Interface.fileUrl + safetyMeasures.images![0]),
              const Spacer(),
              _getInvolveView(title: '是否涉及', value: safetyMeasures.isInvolve == 0 ? '未涉及' : '涉及'),
              AppGaps.hGap14,
              // _getInvolveView(title: '确定人', value: safetyMeasures.userName!),
              Container(
                width: 90.w,
                height: 67.w,
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(4.w),
                    image: DecorationImage(
                      image: NetworkImage(Interface.fileUrl + safetyMeasures.userSign![0]),
                      fit: BoxFit.fill,
                    )),
              ).clickShowLarge(url: Interface.fileUrl + safetyMeasures.userSign![0]),
            ],
          )
        ],
      ),
    );
  }

  ///涉及不涉及样式
  Widget _getInvolveView({required String title, required String value}) {
    return Container(
      width: 90.w,
      height: 67.w,
      decoration: BoxDecoration(
        color: const Color(0xff5C6DFF).withOpacity(0.1),
        borderRadius: BorderRadius.circular(4.r),
      ),
      alignment: Alignment.center,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Text(
            value,
            style: TextStyle(
              fontSize: 13.sp,
              fontWeight: FontWeight.w400,
              color: const Color(0xff495061),
            ),
          ),
          Text(
            title,
            style: TextStyle(
              fontSize: 13.sp,
              fontWeight: FontWeight.w400,
              color: const Color(0xff587DF5),
            ),
          )
        ],
      ),
    );
  }

  ///安全交底意见样式
  Widget _getSafetyDisclosure(ExecuteWorkCheckList workCheck) {
    return Container(
      alignment: Alignment.centerLeft,
      padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 16.w),
      decoration: BoxDecoration(
        color: const Color(0xff7C7D93).withOpacity(0.1),
        borderRadius: BorderRadius.circular(4.r),
      ),
      child: Column(
        children: [
          _getLeftNameRightContent(
            name: workCheck.checkProject!,
            content: workCheck.checkReason!,
            nameColor: const Color(0xff444444),
            contentColor: const Color(0xff3B62FF),
          ),
          _getLeftNameRightSign(
            name: '签字',
            nameColor: const Color(0xff444444),
            sign: workCheck.checkUserSign!,
          ),
          AppGaps.vGap10,
          _getLeftNameRightContent(
            name: '时间',
            content: workCheck.checkDate!,
            nameColor: const Color(0xff444444),
            contentColor: const Color(0xff3B62FF),
            margin: EdgeInsets.zero,
          ),
        ],
      ),
    );
  }

  ///作业申请节点
  Widget _getJobApplication() {
    return Visibility(
        visible: controller.ticketReceiptList != null,
        child: Column(
          children: [
            _getDetailStyleBox(name: '作业申请信息', child: _getJobApplicationByType()),
            AppGaps.vGap20,
          ],
        ));
  }

  ///根据作业票类型获取不同的页面
  Widget _getJobApplicationByType() {
    switch (controller.ticketBigTypeName) {
      case '动火作业':
        return _getFireJobApplication();
      case '受限空间':
      case '盲板抽堵':
      case '高处作业':
        return _getCommonApplication();
      case '动土作业':
      case '断路作业':
        return _getCommonApplication(haveOperator: false);
      case '吊装作业':
        return _getHoistingApplication();
      case '临时用电':
        return _getElectricityApplication();
      default:
        return Container();
    }
  }

  ///作业申请节点-动火作业
  Widget _getFireJobApplication() {
    return Column(
      children: [
        _getBlueTextGreyBg(text: '作业内容：${controller.ticketReceiptList!.ticketPlanList!.ticketContent!}'),
        AppGaps.vGap14,
        _getLeftNameRightContent(
            name: '作业申请单位：', content: controller.ticketReceiptList!.ticketPlanList!.applyDepartmentName!),
        _getLeftNameRightContent(name: '作业申请时间：', content: controller.ticketReceiptList!.createDate!),
        _getLeftNameRightContent(
            name: '动火地点及动火部位：', content: controller.ticketReceiptList!.workOtherDataDTO!.workPlace!),
        _getLeftNameRightContent(name: '动火作业级别：', content: controller.ticketReceiptList!.ticketTypeName!),
        _getLeftNameRightContent(
            name: '动火方式：',
            content: _getWorkModeName(controller.ticketReceiptList!.workOtherDataDTO!.workModeConfigs!)),
        _getLeftNameRightContent(
            name: '动火人及证书编号：', content: _getWorkPeopleName(controller.ticketReceiptList!.operatorLists!)),
        _getLeftNameRightContent(name: '作业单位：', content: controller.ticketReceiptList!.workDepartmentName!),
        _getLeftNameRightContent(
          name: '作业负责人：',
          content: _getNameByType(
            controller.ticketReceiptList!.operatorLists!,
            type: 1,
          ),
          margin: EdgeInsets.zero,
        ),
      ],
    );
  }

  ///作业申请节点-通用类型节点
  Widget _getCommonApplication({bool haveOperator = true}) {
    return Column(children: [
      _getBlueTextGreyBg(text: '作业内容：${controller.ticketReceiptList!.ticketPlanList!.ticketContent!}'),
      AppGaps.vGap14,
      _getLeftNameRightContent(
          name: '作业申请单位：', content: controller.ticketReceiptList!.ticketPlanList!.applyDepartmentName!),
      _getLeftNameRightContent(name: '作业申请时间：', content: controller.ticketReceiptList!.createDate!),
      Visibility(
          visible: haveOperator,
          child: _getLeftNameRightContent(
              name: '作业人及编号：', content: _getWorkPeopleName(controller.ticketReceiptList!.operatorLists!))),
      _getLeftNameRightContent(name: '作业单位：', content: controller.ticketReceiptList!.workDepartmentName!),
      _getLeftNameRightContent(
        name: '作业负责人：',
        content: _getNameByType(
          controller.ticketReceiptList!.operatorLists!,
          type: 1,
        ),
        margin: EdgeInsets.zero,
      ),
    ]);
  }

  ///作业申请节点-吊装作业节点
  Widget _getHoistingApplication() {
    return Column(children: [
      _getBlueTextGreyBg(text: '作业内容：${controller.ticketReceiptList!.ticketPlanList!.ticketContent!}'),
      AppGaps.vGap14,
      _getLeftNameRightContent(
          name: '作业申请单位：', content: controller.ticketReceiptList!.ticketPlanList!.applyDepartmentName!),
      _getLeftNameRightContent(name: '作业申请时间：', content: controller.ticketReceiptList!.createDate!),
      _getLeftNameRightContent(
          name: '吊装作业人及证书编号：', content: _getWorkPeopleName(controller.ticketReceiptList!.operatorLists!)),
      _getLeftNameRightContent(
        name: '司索人：',
        content: _getNameByType(
          controller.ticketReceiptList!.operatorLists!,
          type: 4,
        ),
      ),
      _getLeftNameRightContent(
        name: '指挥人：',
        content: _getNameByType(
          controller.ticketReceiptList!.operatorLists!,
          type: 5,
        ),
      ),
      _getLeftNameRightContent(
          name: '作业单位：', content: controller.ticketReceiptList!.workDepartmentName!, margin: EdgeInsets.zero),
    ]);
  }

  ///作业申请节点-临时用电节点
  Widget _getElectricityApplication() {
    return Column(children: [
      _getBlueTextGreyBg(text: '作业内容：${controller.ticketReceiptList!.ticketPlanList!.ticketContent!}'),
      AppGaps.vGap14,
      _getLeftNameRightContent(
          name: '作业申请单位：', content: controller.ticketReceiptList!.ticketPlanList!.applyDepartmentName!),
      _getLeftNameRightContent(name: '作业申请时间：', content: controller.ticketReceiptList!.createDate!),
      _getLeftNameRightContent(
          name: '作业人及编号：', content: _getWorkPeopleName(controller.ticketReceiptList!.operatorLists!)),
      _getLeftNameRightContent(name: '作业单位：', content: controller.ticketReceiptList!.workDepartmentName!),
      _getLeftNameRightContent(
        name: '作业负责人：',
        content: _getNameByType(
          controller.ticketReceiptList!.operatorLists!,
          type: 1,
        ),
        margin: EdgeInsets.zero,
      ),
    ]);
  }

  ///获取作业方式名称
  String _getWorkModeName(List<WorkModeConfigEntity> list) {
    return list.map((e) => e.workMode).join(',');
  }

  ///获取作业人及作业编号
  String _getWorkPeopleName(List<ExecuteTicketReceiptListOperatorLists> list) {
    //查找type为0的数据
    return list.where((element) => element.operatorType == 0).map((item) {
      return '${item.operatorUserName}:${item.operatorCertificateId}';
    }).join(',');
  }

  ///获取对应类型人员名称
  String _getNameByType(List<ExecuteTicketReceiptListOperatorLists> list, {int type = 0}) {
    return list.where((element) => element.operatorType == type).map((item) {
      return '${item.operatorUserName}';
    }).join(',');
  }

  ///气体分析节点
  Widget _getGasAnalysis() {
    return Visibility(
        visible: controller.ticketGasList != null && controller.ticketGasList!.isNotEmpty,
        child: Column(
          children: [
            _getDetailStyleBox(
                name: '气体分析信息',
                child: ListView.separated(
                  itemCount: controller.ticketGasList != null ? controller.ticketGasList!.length : 0,
                  shrinkWrap: true,
                  physics: const NeverScrollableScrollPhysics(),
                  itemBuilder: (context, index) {
                    return _getGasAnalysisView(controller.ticketGasList![index]);
                  },
                  separatorBuilder: (BuildContext context, int index) {
                    return AppGaps.vGap20;
                  },
                )),
            AppGaps.vGap20,
          ],
        ));
  }

  ///关联的其他特殊作业及安全作业票编号
  Widget _getOtherTicketNo() {
    return controller.ticketReceiptList != null
        ? Column(
            children: [
              _getDetailStyleBox(
                name: '关联的其他特殊作业及安全作业票编号',
                child: _getBlueTextGreyBg(
                    text: controller.ticketReceiptList!.otherTicketNo!.isEmpty
                        ? '暂无'
                        : controller.ticketReceiptList!.otherTicketNo!.map((e) => e).join('，')),
              ),
              AppGaps.vGap20,
            ],
          )
        : Container();
  }

  ///风险辨识结果
  Widget _getTicketIdentity() {
    return controller.ticketReceiptList != null
        ? Column(
            children: [
              _getDetailStyleBox(
                name: '风险辨识结果',
                child: Container(
                  padding: EdgeInsets.all(12.w),
                  alignment: Alignment.topLeft,
                  decoration: BoxDecoration(
                    color: const Color(0xffF7F7FB),
                    border: Border.all(
                      color: const Color(0xffEBEDF0),
                      width: 1.w,
                    ),
                    borderRadius: BorderRadius.circular(4.r),
                  ),
                  constraints: BoxConstraints(minHeight: 80.w),
                  child: Text(
                    controller.ticketReceiptList!.ticketPlanList!.ticketIdentityName!.isEmpty
                        ? '暂无'
                        : controller.ticketReceiptList!.ticketPlanList!.ticketIdentityName!,
                    style: TextStyle(
                      fontSize: 13.sp,
                      fontWeight: FontWeight.w400,
                      color: const Color(0xff9FA5B0),
                    ),
                  ),
                ),
              ),
              AppGaps.vGap20,
            ],
          )
        : Container();
  }

  ///作业实施时间
  Widget _getWorkTime() {
    return controller.ticketReceiptList != null
        ? Column(
            children: [
              _getDetailStyleBox(
                name: '作业实施时间',
                child: _getBlueTextGreyBg(
                    text:
                        '自${controller.ticketReceiptList!.ticketPlanList!.planStartDate}至${controller.ticketReceiptList!.ticketPlanList!.planEndDate}'),
              ),
              AppGaps.vGap20,
            ],
          )
        : Container();
  }

  ///安全措施
  Widget _getSafetyMeasures() {
    if (controller.safetyMeasuresList == null ||
        controller.safetyMeasuresList!.isEmpty ||
        controller.safetyMeasuresList![0].images!.isEmpty) {
      return Container();
    }

    return Column(
      children: [
        _getDetailStyleBox(
          name: '安全措施',
          child: ListView.separated(
            itemCount: controller.safetyMeasuresList!.length,
            shrinkWrap: true,
            physics: const NeverScrollableScrollPhysics(),
            itemBuilder: (context, index) {
              return _getSafetyMeasuresView(controller.safetyMeasuresList![index]);
            },
            separatorBuilder: (BuildContext context, int index) {
              return AppGaps.vGap20;
            },
          ),
        ),
        AppGaps.vGap20,
      ],
    );
  }

  ///安全交底信息
  Widget _getSafetyDisclosureView() {
    if (controller.ticketDiscloseList == null || controller.ticketDiscloseList!.isEmpty) {
      return Container();
    }
    return _getDetailStyleBox(
      name: '安全交底信息',
      child: Column(
        children: [
          Column(
            children: [
              Container(
                alignment: Alignment.centerLeft,
                padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w),
                decoration: BoxDecoration(
                  color: const Color(0xffF7F7FB),
                  borderRadius: BorderRadius.circular(4.r),
                ),
                child: Column(
                  children: [
                    _getLeftNameRightSign(
                      name: '安全交底人',
                      sign: controller.getDiscloseNameById(0),
                    ),
                    _getLeftNameRightSign(
                      name: '接受交底人',
                      sign: controller.getDiscloseNameById(1),
                    ),
                    _getLeftNameRightSign(
                      name: '监护人',
                      sign: controller.getDiscloseNameById(2),
                      margin: EdgeInsets.zero,
                    ),
                  ],
                ),
              ),
              AppGaps.vGap20,
            ],
          ),
          controller.workCheckList == null
              ? Container()
              : ListView.separated(
                  itemCount: controller.workCheckList!.length,
                  shrinkWrap: true,
                  physics: const NeverScrollableScrollPhysics(),
                  itemBuilder: (context, index) {
                    return _getSafetyDisclosure(controller.workCheckList![index]);
                  },
                  separatorBuilder: (BuildContext context, int index) {
                    return AppGaps.vGap20;
                  },
                )
        ],
      ),
    );
  }

  ///左侧名称-右侧内容-左右布局
  ///[name]名称
  ///[nameColor]名称颜色
  ///[sign]签名
  ///[margin]外边距
  Widget _getLeftNameRightSign(
      {String name = '',
      Color? nameColor,
      List<String> sign = const [],
      EdgeInsetsGeometry margin = const EdgeInsets.only(bottom: 10)}) {
    return Container(
      margin: margin,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            name,
            style: TextStyle(
              fontSize: 13.sp,
              fontWeight: FontWeight.w400,
              color: nameColor ?? const Color(0xff5C6DFF),
            ),
          ),
          AppGaps.hGap10,
          Expanded(
              child: Wrap(
            // 主轴(水平)方向间距
            spacing: 2.w,
            // 纵轴（垂直）方向间距
            runSpacing: 10.w,
            // alignment: WrapAlignment.start,
            // 将Wrap小部件靠右对齐
            alignment: WrapAlignment.end,
            direction: Axis.horizontal,
            children: sign.map<Widget>((item) {
              return Container(
                width: 76.w,
                height: 36.w,
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(4.w),
                    color: Colors.white,
                    border: Border.all(
                      color: const Color(0xFFEFF2F6),
                      width: 1,
                    ),
                    image: DecorationImage(
                      image: NetworkImage(Interface.fileUrl + item),
                    )),
              ).clickShowLarge(url: Interface.fileUrl + item);
            }).toList(),
          ))
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        init: controller,
        initState: (_) async {
          await controller.initDate(ticketReceiptId);
        },
        builder: (_) {
          return Container(
            padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 20.w),
            child: SingleChildScrollView(
              child: Column(
                children: [
                  //作业申请信息
                  _getJobApplication(),
                  //气体分析信息
                  _getGasAnalysis(),
                  //关联的其他特殊作业及安全作业票编号
                  _getOtherTicketNo(),
                  //风险辨识结果
                  _getTicketIdentity(),
                  //作业实施时间
                  _getWorkTime(),
                  //安全措施
                  _getSafetyMeasures(),
                  //安全交底信息
                  _getSafetyDisclosureView(),
                ],
              ),
            ),
          );
        });
  }
}
